<template>
	<view class="contaier">
		<view v-if="!driverRegisterInfo || driverRegisterInfo.status===0">
			<view class="tips">
				车主注册需【实物拍摄】以下资料
			</view>
			<view class="b">
				<view class="item">
					<view class="left">
						<image src="@/static/img/shenfenzheng.png" style="width: 90rpx; height: 73rpx;"></image>
						<view class="txt-box">
							<view class="title">身份证</view>
							<view class="desc">
								本人证件，年龄18-70周岁之间
							</view>
						</view>
					</view>
					<view class="btn" @click="toUploadIdCardImg">
						{{driverRegisterInfo.idcardFrontImg ? '已拍摄':'去拍摄'}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						<image src="@/static/img/jiashizheng.png" style="width: 90rpx; height: 73rpx;"></image>
						<view class="txt-box">
							<view class="title">驾驶证</view>
							<view class="desc">
								驾龄需满1年，准驾车型在C2以上
							</view>
						</view>
					</view>
					<view class="btn" @click="toUploadDrivercertImg">
						{{driverRegisterInfo.driverCertImg ? '已拍摄':'去拍摄'}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						<image src="@/static/img/xingshizheng.png" style="width: 90rpx; height: 73rpx;"></image>
						<view class="txt-box">
							<view class="title">行驶证</view>
							<view class="desc">
								车龄15年以内，座位数7坐以内
							</view>
						</view>
					</view>
					<view class="btn" @click="toUploadDrivingCertImg">
						{{driverRegisterInfo.drivingCertImg ? '已拍摄':'去拍摄'}}
					</view>
				</view>
				<view class="item">
					<view class="left">
						<image src="@/static/img/cheliangrenzheng.png" style="width: 90rpx; height: 73rpx;"></image>
						<view class="txt-box">
							<view class="title">真实车辆</view>
							<view class="desc">
								请确保车辆在您身边打开双闪， 从正后方拍摄车辆
							</view>
						</view>
					</view>
					<view class="btn" @click="toUploadCarImg">
						{{driverRegisterInfo.carImg ? '已拍摄':'去拍摄'}}
					</view>
				</view>
			</view>
		</view>
		<view v-if="driverRegisterInfo && driverRegisterInfo.status===0" class="btn-submit-box">
			<view class="btn-submit" @click="toSubmit">
				提交资料
			</view>
		</view>
		<view v-if="driverRegisterInfo && driverRegisterInfo.status===1" class="audit-cnt-box">
			<image src="@/static/img/shenhe-ing.png" style="width: 267rpx; height: 182rpx;"></image>
			<view class="title">
				您的证件正在审核中
			</view>
			<view class="desc">
				审核预计需要1-3个工作日，请耐心等待
			</view>
		</view>
		<view v-if="driverRegisterInfo && driverRegisterInfo.status===3" class="audit-cnt-box">
			<image src="@/static/img/shenhe-fail.png" style="width: 267rpx; height: 182rpx;"></image>
			<view class="title">
				资料审核失败
			</view>
			<view class="desc">
				{{driverRegisterInfo.auditRemark ? driverRegisterInfo.auditRemark : '请重新上传资料'}}
			</view>
			<view class="btn" @click="clickReUplod">重新上传</view>
		</view>
		
		<uni-popup ref="message" type="message">
			<uni-popup-message :type="msgType" :message="msgText" :duration="3000"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
import { 
	getDriverRegInfo,
	driverRegSubmit 
	} from '@/api/api.js'
	
	export default {
		data() {
			return {
				msgType: '',
				msgText: '',
				driverRegisterInfo: null
			}
		},
		onShow() {
			this.getDriverRegInfo();
		},
		methods: {
			getDriverRegInfo(){
				getDriverRegInfo().then(res => {
					this.driverRegisterInfo = res.data;
					uni.setStorageSync('driverRegisterInfo', this.driverRegisterInfo);
				})
			},
			clickReUplod(){
				this.driverRegisterInfo.status=0;
			},
			toUploadIdCardImg(){
				uni.navigateTo({
					url:'/pages/xyqc/sfc/driver/register/idcard'
				})
			},
			toUploadDrivercertImg(){
				uni.navigateTo({
					url:'/pages/xyqc/sfc/driver/register/drivercert'
				})
			},
			toUploadDrivingCertImg(){
				uni.navigateTo({
					url:'/pages/xyqc/sfc/driver/register/drivingcert'
				})
			},
			toUploadCarImg(){
				uni.navigateTo({
					url:'/pages/xyqc/sfc/driver/register/car'
				})
			},
			toSubmit(){
				let p = this.driverRegisterInfo;
				p.submit = true;
				p.status = 1;
				driverRegSubmit(p).then(res => {
					if(res && res.data){
						this.msgType = 'success';
						this.msgText = '提交成功';
						this.$refs.message.open();
						setTimeout(()=>{
							this.driverRegisterInfo.status===1;
						}, 3000);
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.contaier{
		height: 100%;
		background-color: #FFFFFF !important;
		.tips{
			border-top: 1rpx solid #DFDFDF;
			padding: 30rpx;
			font-size: 33rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			color: #333333;
		}
		.b{
			padding: 0 30rpx;
			width: 100%;
			.item{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 40rpx 0;
				border-bottom: 1rpx solid #DFDFDF;
				.left{
					flex: 1;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					.txt-box{
						padding-left: 27rpx;
						.title{
							font-size: 33rpx;
							font-family: PingFangSC, PingFang SC;
							font-weight: 600;
							color: #333333;
							line-height: 47rpx;
						}
						.desc{
							font-size: 25rpx;
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							color: #999999;
							line-height: 35rpx;
						}
					}
				}
				.btn{
					display: flex;
					justify-content: center;
					align-items: center;
					margin-left: 60rpx;
					width: 168rpx;
					height: 70rpx;
					background: #6FC65E;
					border-radius: 42rpx;
					font-size: 29rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
				}
			}
		}
	}
	.btn-submit-box{
		position: fixed;
		left: 30rpx;
		right: 30rpx;
		bottom: 30rpx;
	}
	.btn-submit{
		width: 100%;
		height: 94rpx;
		background: #6FC65E;
		border-radius: 47rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 38rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
	}
	.audit-cnt-box{
		width: 100%;
		margin-top: 134rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.title{
			margin-top: 60rpx;
			font-size: 33rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			color: #333333;
		}
		.desc{
			margin-top: 30rpx;
			font-size: 29rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			color: #999999;
		}
		.btn{
			display: flex;
			justify-content: center;
			align-items: center;
			margin-top: 130rpx;
			width: 100%;
			height: 94rpx;
			background: #6FC65E;
			border-radius: 47rpx;
			font-size: 38rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>
